<?php

namespace App\Http\Controllers\admin\User;

use App\Http\Controllers\Controller;
use App\Models\NodeModel;
use App\Service\Auth;
use Illuminate\Http\Request;

class BackGroundController extends Controller
{
    /**
     * @后台主页面
     * @user wsg
     * @method get
     * @url http://www.health.com/user/back_admin
     * @data
     * @return \Illuminate\Http\Response
     */
    public function backAdmin()
    {
        $auth = session('authUser');
        $node = NodeModel::where('is_menu',1);
        if ($auth === true){
            $userAuth = $node->get()->toArray();
        }else{
            //取出权限的id
            $nodeIds = array_values($auth);
            $userAuth = $node->whereIn('id', $nodeIds)->get()->toArray();
        }
        $data = Auth::sonLevel($userAuth);
        return view('advocate.back',compact('data'));
    }
}
